#pragma once
#include <iostream>
using namespace std;
namespace zkf
{
	class string
	{
	public:
		string(const char* str = "")
		{
			size_t n = strlen(str);
			_str = new char[n + 1];
			for (size_t i = 0; i < n; i++)
			{
				_str[i] = str[i];
			}
			_str[n] = '\0';
		}
		const char* std()const
		{
			return _str;
		}
		void swap(string& s1, string& s2)
		{
			std::swap(s1._str, s2._str);
			std::swap(s1._capacity, s2._capacity);
			std::swap(s1._size, s2._size);
		}
		string(const string& s)
		{
			string tmp(s._str);
			swap(*this, tmp);
		}
		string& operator=(string s)
		{
			swap(*this, s);
			return *this;
		}
		~string()
		{
			delete[] _str;
			_str = nullptr;
		}
	private:
		char* _str = nullptr;
		size_t _capacity = 0;
		size_t _size = 0;
	};
}
